package com.cy.sys.common.pojo;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class JsonResult {
    /*响应状态码(有的人用 code)*/
    private Integer state=1;//1 表示 ok,0 表示 error,.....
    /*状态码对应的信息*/
    private String message="ok";
    /*正确的响应数据*/
    private Object data;

    public JsonResult(){}

    public JsonResult(Integer state, String message) {
        this.state = state;
        this.message = message;
    }

    public JsonResult(Integer state, String message, Object data) {
        this.state = state;
        this.message = message;
        this.data = data;
    }

    public JsonResult(Object data) {
        this.data = data;
    }
    //当出现异常时，可以通过此构造方法对异常信息进行封装
    public JsonResult(Throwable e){
        this(0,e.getMessage());
    }

}
